import synMenuConfig from '../router/synMenuConfig'
function addRouter(routerlist) {
  routerlist.forEach(e => {
    delete e.id
    e.component = synMenuConfig(e.component) // 匹配组件
    if (e.redirect === '' || e.redirect === null) {
      delete e.redirect
    }
    if (e.name === '' || e.name === null) {
      delete e.name
    }
    if (e.icon !== '' && e.title !== '') {
      e.meta = {
        title: e.name,
        icon: e.icon
      }
    } else if (e.icon === '' && e.title !== '') {
      e.meta = {
        title: e.name
      }
    }
    delete e.icon
    // delete e.name
    if (e.type === '1') {
      delete e.children
    }
    if (e.children != null) {
      addRouter(e.children)
    }
    if (e.children === null) {
      delete e.children
    }
  }
  )
  return routerlist
}
export { addRouter }
